package com.hooya.fa.eu.biz.controller;

import com.hooya.fa.eu.biz.service.ReportService;
import com.hooya.integrated.common.core.util.R;
import com.hooya.integrated.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 报表
 * @Author : Zongz
 * @Copyright Copyright (c) 豪雅集团
 * @Create 2023/12/21
 * @Version 1.0.0
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "报表")
@RequestMapping("/report")
public class ReportController {

    private final ReportService reportService;

    @GetMapping("/inout")
    @Inner(value = false)
    @Operation(summary = "inout报表导出【√】", description = "inout报表导出")
    public R inoutReport(@RequestParam("startDate") String startDate,
                         @RequestParam("endDate") String endDate) {
        reportService.inoutReport(startDate, endDate);
        return R.ok();
    }

    @GetMapping("/stock/list")
    @Inner(value = false)
    @Operation(summary = "stockList报表导出【√】", description = "stockList报表导出")
    public R stockListReport(@RequestParam("startDate") String startDate,
                             @RequestParam("endDate") String endDate) {
        reportService.stockListReport(startDate, endDate);
        return R.ok();
    }

    @PostMapping("/profit/check/init")
    @Inner(value = false)
    @Operation(summary = "初始化利润检查表【√】", hidden = true,
            description = "根据csv文件，将报表存入数据库【时间格式：2024-01】")
    public R initProfitCheck(@RequestParam("date") String date) {
        reportService.initProfitCheck(date);
        return R.ok();
    }

    @GetMapping("/generator/profit")
    @Inner(value = false)
    @Operation(summary = "利润检查表报表导出【√】", description = "利润检查表报表导出")
    public R profitCheckReport(@RequestParam("startDate") String startDate,
                               @RequestParam("endDate") String endDate) {
        reportService.profitCheckReport(startDate, endDate);
        return R.ok();
    }

    @GetMapping("/check/profit")
    @Inner(value = false)
    @Operation(summary = "校验利润检查生成数据【√】", description = "两张表进行校验")
    public R checkProfit(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        reportService.checkProfitKc(startDate, endDate);
        return R.ok();
    }

}
